package com.zcx.utils;

/**
 * @Author:
 * @DATE:2023/5/9 11:29
 * @Description:
 * @Version 1.0
 */

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.vividsolutions.jts.geom.*;
import com.vividsolutions.jts.io.ParseException;
import com.vividsolutions.jts.io.WKTReader;
import org.geotools.data.*;
import org.geotools.data.shapefile.ShapefileDataStore;
import org.geotools.data.shapefile.ShapefileDataStoreFactory;
import org.geotools.data.simple.SimpleFeatureCollection;
import org.geotools.data.simple.SimpleFeatureIterator;
import org.geotools.data.simple.SimpleFeatureSource;
import org.geotools.feature.simple.SimpleFeatureBuilder;
import org.geotools.feature.simple.SimpleFeatureTypeBuilder;
import org.geotools.geojson.GeoJSONUtil;
import org.geotools.geojson.feature.FeatureJSON;
import org.geotools.geojson.geom.GeometryJSON;
import org.geotools.referencing.crs.DefaultGeographicCRS;
import org.opengis.feature.simple.SimpleFeature;
import org.opengis.feature.simple.SimpleFeatureType;
import org.opengis.referencing.crs.CoordinateReferenceSystem;

import java.io.File;
import java.io.IOException;
import java.io.Reader;
import java.io.StringWriter;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import static com.zcx.utils.CscUtils.getImageXY;


public class ShpFileSpelitter {

    private static WKTReader reader = new WKTReader();

    private static final String GEO_JSON_TYPE = "GeometryCollection";

    private static final String WKT_TYPE = "GEOMETRYCOLLECTION";

    private String name;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void setvalue(String name){
        this.name=name;
    }
    public static void main(String[] args) throws IOException, ParseException {
//        List<String> d=shptocf("D:\\data\\data\\file\\caiqiemian.shp","F:\\shp\\","拆分");

//        String a="polygon ((112.884859671972 27.586792436465,112.884859671972 27.656395905155,112.951018216452 27.656395905155,112.951018216452 27.586792436465,112.884859671972 27.586792436465))";
//        String b="{\"type\":\"FeatureCollection\",\"features\":[{\"type\":\"Feature\",\"geometry\":{\"type\":\"MultiPolygon\",\"coordinates\":[[[[112.9169,27.6178],[112.9169,27.6179],[112.9169,27.618],[112.9169,27.6181],[112.9169,27.6182],[112.9169,27.6183],[112.9169,27.6184],[112.9169,27.6185],[112.917,27.6186],[112.917,27.6187],[112.917,27.6188],[112.917,27.6189],[112.917,27.619],[112.9171,27.6191],[112.9171,27.6192],[112.9171,27.6193],[112.9171,27.6194],[112.9172,27.6195],[112.9172,27.6196],[112.9172,27.6197],[112.9173,27.6198],[112.9173,27.6199],[112.9173,27.62],[112.9174,27.62],[112.9174,27.6201],[112.9175,27.6202],[112.9175,27.6203],[112.9176,27.6204],[112.9176,27.6204],[112.9177,27.6205],[112.9177,27.6206],[112.9178,27.6207],[112.9178,27.6207],[112.9179,27.6208],[112.9179,27.6209],[112.918,27.6209],[112.918,27.621],[112.9181,27.6211],[112.9182,27.6211],[112.9182,27.6212],[112.9183,27.6212],[112.9184,27.6213],[112.9184,27.6214],[112.9185,27.6214],[112.9186,27.6215],[112.9186,27.6215],[112.9187,27.6215],[112.9188,27.6216],[112.9188,27.6216],[112.9189,27.6217],[112.919,27.6217],[112.9191,27.6217],[112.9191,27.6218],[112.9192,27.6218],[112.9193,27.6218],[112.9194,27.6218],[112.9194,27.6219],[112.9195,27.6219],[112.9196,27.6219],[112.9197,27.6219],[112.9197,27.6219],[112.9198,27.6219],[112.9199,27.6219],[112.92,27.6219],[112.92,27.6219],[112.9201,27.6219],[112.9202,27.6219],[112.9203,27.6219],[112.9203,27.6219],[112.9204,27.6219],[112.9205,27.6219],[112.9206,27.6219],[112.9207,27.6219],[112.9207,27.6218],[112.9208,27.6218],[112.9209,27.6218],[112.921,27.6218],[112.921,27.6217],[112.9211,27.6217],[112.9212,27.6217],[112.9212,27.6216],[112.9213,27.6216],[112.9214,27.6215],[112.9215,27.6215],[112.9215,27.6215],[112.9216,27.6214],[112.9217,27.6214],[112.9217,27.6213],[112.9218,27.6212],[112.9218,27.6212],[112.9219,27.6211],[112.922,27.6211],[112.922,27.621],[112.9221,27.6209],[112.9222,27.6209],[112.9222,27.6208],[112.9223,27.6207],[112.9223,27.6207],[112.9224,27.6206],[112.9224,27.6205],[112.9225,27.6204],[112.9225,27.6204],[112.9226,27.6203],[112.9226,27.6202],[112.9227,27.6201],[112.9227,27.62],[112.9227,27.62],[112.9228,27.6199],[112.9228,27.6198],[112.9228,27.6197],[112.9229,27.6196],[112.9229,27.6195],[112.9229,27.6194],[112.923,27.6193],[112.923,27.6192],[112.923,27.6191],[112.923,27.619],[112.9231,27.6189],[112.9231,27.6188],[112.9231,27.6187],[112.9231,27.6186],[112.9231,27.6185],[112.9231,27.6184],[112.9232,27.6183],[112.9232,27.6182],[112.9232,27.6181],[112.9232,27.618],[112.9232,27.6179],[112.9232,27.6178],[112.9232,27.6177],[112.9232,27.6176],[112.9232,27.6175],[112.9232,27.6174],[112.9232,27.6173],[112.9231,27.6172],[112.9231,27.6171],[112.9231,27.617],[112.9231,27.6169],[112.9231,27.6169],[112.9231,27.6168],[112.923,27.6167],[112.923,27.6166],[112.923,27.6165],[112.923,27.6164],[112.9229,27.6163],[112.9229,27.6162],[112.9229,27.6161],[112.9228,27.616],[112.9228,27.6159],[112.9228,27.6158],[112.9227,27.6157],[112.9227,27.6157],[112.9227,27.6156],[112.9226,27.6155],[112.9226,27.6154],[112.9225,27.6153],[112.9225,27.6152],[112.9224,27.6152],[112.9224,27.6151],[112.9223,27.615],[112.9223,27.615],[112.9222,27.6149],[112.9222,27.6148],[112.9221,27.6147],[112.922,27.6147],[112.922,27.6146],[112.9219,27.6146],[112.9218,27.6145],[112.9218,27.6144],[112.9217,27.6144],[112.9217,27.6143],[112.9216,27.6143],[112.9215,27.6142],[112.9215,27.6142],[112.9214,27.6141],[112.9213,27.6141],[112.9212,27.6141],[112.9212,27.614],[112.9211,27.614],[112.921,27.614],[112.921,27.6139],[112.9209,27.6139],[112.9208,27.6139],[112.9207,27.6139],[112.9207,27.6138],[112.9206,27.6138],[112.9205,27.6138],[112.9204,27.6138],[112.9203,27.6138],[112.9203,27.6138],[112.9202,27.6138],[112.9201,27.6138],[112.92,27.6138],[112.92,27.6138],[112.9199,27.6138],[112.9198,27.6138],[112.9197,27.6138],[112.9197,27.6138],[112.9196,27.6138],[112.9195,27.6138],[112.9194,27.6138],[112.9194,27.6139],[112.9193,27.6139],[112.9192,27.6139],[112.9191,27.6139],[112.9191,27.614],[112.919,27.614],[112.9189,27.614],[112.9188,27.6141],[112.9188,27.6141],[112.9187,27.6141],[112.9186,27.6142],[112.9186,27.6142],[112.9185,27.6143],[112.9184,27.6143],[112.9184,27.6144],[112.9183,27.6144],[112.9182,27.6145],[112.9182,27.6146],[112.9181,27.6146],[112.918,27.6147],[112.918,27.6147],[112.9179,27.6148],[112.9179,27.6149],[112.9178,27.615],[112.9178,27.615],[112.9177,27.6151],[112.9177,27.6152],[112.9176,27.6153],[112.9176,27.6153],[112.9175,27.6154],[112.9175,27.6155],[112.9174,27.6156],[112.9174,27.6157],[112.9173,27.6157],[112.9173,27.6158],[112.9173,27.6159],[112.9172,27.616],[112.9172,27.6161],[112.9172,27.6162],[112.9171,27.6163],[112.9171,27.6164],[112.9171,27.6165],[112.9171,27.6166],[112.917,27.6167],[112.917,27.6168],[112.917,27.6169],[112.917,27.617],[112.917,27.617],[112.9169,27.6171],[112.9169,27.6172],[112.9169,27.6173],[112.9169,27.6174],[112.9169,27.6175],[112.9169,27.6176],[112.9169,27.6177],[112.9169,27.6178]]]]},\"properties\":{\"Id\":0,\"name\":\"羊\",\"拆分\":\"喜\"},\"id\":\"范围2.1\"},{\"type\":\"Feature\",\"geometry\":{\"type\":\"MultiPolygon\",\"coordinates\":[[[[112.8753,27.6335],[112.8755,27.6336],[112.8756,27.6337],[112.8758,27.6337],[112.876,27.6338],[112.8762,27.6338],[112.8763,27.6339],[112.8765,27.6339],[112.8767,27.634],[112.8768,27.634],[112.877,27.634],[112.8772,27.6341],[112.8774,27.6341],[112.8775,27.6341],[112.8777,27.6341],[112.8779,27.6342],[112.8781,27.6342],[112.8782,27.6342],[112.8784,27.6342],[112.8786,27.6342],[112.8787,27.6342],[112.8789,27.6342],[112.8791,27.6342],[112.8792,27.6342],[112.8794,27.6342],[112.8796,27.6342],[112.8797,27.6341],[112.8799,27.6341],[112.8801,27.6341],[112.8802,27.6341],[112.8804,27.634],[112.8805,27.634],[112.8807,27.6339],[112.8808,27.6339],[112.881,27.6339],[112.8811,27.6338],[112.8813,27.6338],[112.8814,27.6337],[112.8816,27.6336],[112.8817,27.6336],[112.8818,27.6335],[112.882,27.6334],[112.8821,27.6334],[112.8822,27.6333],[112.8823,27.6332],[112.8825,27.6331],[112.8826,27.6331],[112.8827,27.633],[112.8828,27.6329],[112.8829,27.6328],[112.883,27.6327],[112.8831,27.6326],[112.8832,27.6325],[112.8833,27.6324],[112.8834,27.6323],[112.8835,27.6322],[112.8836,27.6321],[112.8837,27.632],[112.8837,27.6319],[112.8838,27.6317],[112.8839,27.6316],[112.8839,27.6315],[112.884,27.6314],[112.8841,27.6313],[112.8841,27.6311],[112.8842,27.631],[112.8842,27.6309],[112.8842,27.6307],[112.8843,27.6306],[112.8843,27.6305],[112.8843,27.6304],[112.8844,27.6302],[112.8844,27.6301],[112.8844,27.6299],[112.8844,27.6298],[112.8844,27.6297],[112.8844,27.6295],[112.8844,27.6294],[112.8844,27.6293],[112.8844,27.6291],[112.8844,27.629],[112.8844,27.6288],[112.8843,27.6287],[112.8843,27.6286],[112.8843,27.6284],[112.8842,27.6283],[112.8842,27.6281],[112.8841,27.628],[112.8841,27.6278],[112.884,27.6277],[112.884,27.6276],[112.8839,27.6274],[112.8839,27.6273],[112.8838,27.6271],[112.8837,27.627],[112.8836,27.6269],[112.8836,27.6267],[112.8835,27.6266],[112.8834,27.6265],[112.8833,27.6263],[112.8832,27.6262],[112.8831,27.6261],[112.883,27.6259],[112.8829,27.6258],[112.8828,27.6257],[112.8827,27.6256],[112.8826,27.6254],[112.8825,27.6253],[112.8823,27.6252],[112.8822,27.6251],[112.8821,27.625],[112.882,27.6249],[112.8818,27.6248],[112.8817,27.6246],[112.8815,27.6245],[112.8814,27.6244],[112.8813,27.6243],[112.8811,27.6242],[112.881,27.6241],[112.8808,27.624],[112.8807,27.624],[112.8805,27.6239],[112.8804,27.6238],[112.8802,27.6237],[112.88,27.6236],[112.8799,27.6235],[112.8797,27.6235],[112.8796,27.6234],[112.8794,27.6233],[112.8792,27.6233],[112.8791,27.6232],[112.8789,27.6231],[112.8787,27.6231],[112.8785,27.623],[112.8784,27.623],[112.8782,27.6229],[112.878,27.6229],[112.8779,27.6229],[112.8777,27.6228],[112.8775,27.6228],[112.8773,27.6228],[112.8772,27.6227],[112.877,27.6227],[112.8768,27.6227],[112.8767,27.6227],[112.8765,27.6227],[112.8763,27.6227],[112.8761,27.6227],[112.876,27.6227],[112.8758,27.6227],[112.8756,27.6227],[112.8755,27.6227],[112.8753,27.6227],[112.8751,27.6227],[112.875,27.6227],[112.8748,27.6227],[112.8746,27.6228],[112.8745,27.6228],[112.8743,27.6228],[112.8742,27.6229],[112.874,27.6229],[112.8739,27.623],[112.8737,27.623],[112.8736,27.6231],[112.8734,27.6231],[112.8733,27.6232],[112.8731,27.6232],[112.873,27.6233],[112.8729,27.6234],[112.8727,27.6234],[112.8726,27.6235],[112.8725,27.6236],[112.8724,27.6236],[112.8722,27.6237],[112.8721,27.6238],[112.872,27.6239],[112.8719,27.624],[112.8718,27.6241],[112.8717,27.6242],[112.8716,27.6243],[112.8715,27.6244],[112.8714,27.6245],[112.8713,27.6246],[112.8712,27.6247],[112.8711,27.6248],[112.871,27.6249],[112.871,27.625],[112.8709,27.6251],[112.8708,27.6252],[112.8708,27.6254],[112.8707,27.6255],[112.8706,27.6256],[112.8706,27.6257],[112.8705,27.6259],[112.8705,27.626],[112.8705,27.6261],[112.8704,27.6262],[112.8704,27.6264],[112.8704,27.6265],[112.8703,27.6266],[112.8703,27.6268],[112.8703,27.6269],[112.8703,27.6271],[112.8703,27.6272],[112.8703,27.6273],[112.8703,27.6275],[112.8703,27.6276],[112.8703,27.6277],[112.8703,27.6279],[112.8703,27.628],[112.8704,27.6282],[112.8704,27.6283],[112.8704,27.6285],[112.8705,27.6286],[112.8705,27.6287],[112.8706,27.6289],[112.8706,27.629],[112.8707,27.6292],[112.8707,27.6293],[112.8708,27.6294],[112.8708,27.6296],[112.8709,27.6297],[112.871,27.6299],[112.8711,27.63],[112.8711,27.6301],[112.8712,27.6303],[112.8713,27.6304],[112.8714,27.6305],[112.8715,27.6307],[112.8716,27.6308],[112.8717,27.6309],[112.8718,27.631],[112.8719,27.6312],[112.872,27.6313],[112.8721,27.6314],[112.8722,27.6315],[112.8724,27.6317],[112.8725,27.6318],[112.8726,27.6319],[112.8727,27.632],[112.8729,27.6321],[112.873,27.6322],[112.8732,27.6323],[112.8733,27.6324],[112.8734,27.6325],[112.8736,27.6326],[112.8737,27.6327],[112.8739,27.6328],[112.874,27.6329],[112.8742,27.633],[112.8743,27.6331],[112.8745,27.6332],[112.8747,27.6332],[112.8748,27.6333],[112.875,27.6334],[112.8751,27.6335],[112.8753,27.6335]]]]},\"properties\":{\"Id\":0,\"name\":\"的\",\"拆分\":\"羊\"},\"id\":\"范围2.2\"},{\"type\":\"Feature\",\"geometry\":{\"type\":\"MultiPolygon\",\"coordinates\":[[[[112.9316,27.6022],[112.9318,27.6021],[112.9321,27.602],[112.9323,27.602],[112.9325,27.6019],[112.9328,27.6018],[112.933,27.6017],[112.9332,27.6016],[112.9334,27.6016],[112.9336,27.6015],[112.9339,27.6014],[112.9341,27.6013],[112.9343,27.6012],[112.9345,27.6011],[112.9347,27.6009],[112.9349,27.6008],[112.9351,27.6007],[112.9353,27.6006],[112.9355,27.6005],[112.9357,27.6004],[112.9359,27.6002],[112.9361,27.6001],[112.9363,27.6],[112.9364,27.5998],[112.9366,27.5997],[112.9368,27.5996],[112.9369,27.5994],[112.9371,27.5993],[112.9373,27.5991],[112.9374,27.599],[112.9376,27.5988],[112.9377,27.5987],[112.9378,27.5985],[112.938,27.5984],[112.9381,27.5982],[112.9382,27.5981],[112.9383,27.5979],[112.9385,27.5977],[112.9386,27.5976],[112.9387,27.5974],[112.9388,27.5973],[112.9389,27.5971],[112.939,27.5969],[112.939,27.5968],[112.9391,27.5966],[112.9392,27.5964],[112.9392,27.5963],[112.9393,27.5961],[112.9394,27.5959],[112.9394,27.5958],[112.9395,27.5956],[112.9395,27.5954],[112.9395,27.5953],[112.9395,27.5951],[112.9396,27.5949],[112.9396,27.5948],[112.9396,27.5946],[112.9396,27.5944],[112.9396,27.5943],[112.9396,27.5941],[112.9396,27.594],[112.9395,27.5938],[112.9395,27.5936],[112.9395,27.5935],[112.9394,27.5933],[112.9394,27.5932],[112.9393,27.593],[112.9393,27.5929],[112.9392,27.5927],[112.9392,27.5926],[112.9391,27.5924],[112.939,27.5923],[112.9389,27.5921],[112.9388,27.592],[112.9387,27.5919],[112.9386,27.5917],[112.9385,27.5916],[112.9384,27.5915],[112.9383,27.5913],[112.9382,27.5912],[112.9381,27.5911],[112.9379,27.591],[112.9378,27.5909],[112.9377,27.5907],[112.9375,27.5906],[112.9374,27.5905],[112.9372,27.5904],[112.9371,27.5903],[112.9369,27.5902],[112.9367,27.5901],[112.9366,27.5901],[112.9364,27.59],[112.9362,27.5899],[112.936,27.5898],[112.9358,27.5897],[112.9357,27.5897],[112.9355,27.5896],[112.9353,27.5895],[112.9351,27.5895],[112.9349,27.5894],[112.9347,27.5894],[112.9345,27.5893],[112.9342,27.5893],[112.934,27.5892],[112.9338,27.5892],[112.9336,27.5892],[112.9334,27.5891],[112.9332,27.5891],[112.9329,27.5891],[112.9327,27.5891],[112.9325,27.5891],[112.9322,27.589],[112.932,27.589],[112.9318,27.589],[112.9316,27.589],[112.9313,27.5891],[112.9311,27.5891],[112.9308,27.5891],[112.9306,27.5891],[112.9304,27.5891],[112.9301,27.5892],[112.9299,27.5892],[112.9297,27.5892],[112.9294,27.5893],[112.9292,27.5893],[112.9289,27.5894],[112.9287,27.5894],[112.9285,27.5895],[112.9282,27.5895],[112.928,27.5896],[112.9278,27.5897],[112.9276,27.5897],[112.9273,27.5898],[112.9271,27.5899],[112.9269,27.59],[112.9266,27.59],[112.9264,27.5901],[112.9262,27.5902],[112.926,27.5903],[112.9258,27.5904],[112.9256,27.5905],[112.9253,27.5906],[112.9251,27.5907],[112.9249,27.5909],[112.9247,27.591],[112.9245,27.5911],[112.9243,27.5912],[112.9241,27.5913],[112.924,27.5915],[112.9238,27.5916],[112.9236,27.5917],[112.9234,27.5919],[112.9232,27.592],[112.9231,27.5921],[112.9229,27.5923],[112.9227,27.5924],[112.9226,27.5926],[112.9224,27.5927],[112.9223,27.5929],[112.9221,27.593],[112.922,27.5932],[112.9219,27.5933],[112.9217,27.5935],[112.9216,27.5936],[112.9215,27.5938],[112.9214,27.5939],[112.9213,27.5941],[112.9212,27.5943],[112.9211,27.5944],[112.921,27.5946],[112.9209,27.5948],[112.9208,27.5949],[112.9207,27.5951],[112.9207,27.5953],[112.9206,27.5954],[112.9205,27.5956],[112.9205,27.5958],[112.9204,27.5959],[112.9204,27.5961],[112.9204,27.5963],[112.9203,27.5964],[112.9203,27.5966],[112.9203,27.5968],[112.9203,27.5969],[112.9203,27.5971],[112.9203,27.5973],[112.9203,27.5974],[112.9203,27.5976],[112.9203,27.5977],[112.9203,27.5979],[112.9203,27.5981],[112.9204,27.5982],[112.9204,27.5984],[112.9205,27.5985],[112.9205,27.5987],[112.9206,27.5988],[112.9206,27.599],[112.9207,27.5991],[112.9208,27.5993],[112.9208,27.5994],[112.9209,27.5996],[112.921,27.5997],[112.9211,27.5998],[112.9212,27.6],[112.9213,27.6001],[112.9214,27.6002],[112.9215,27.6004],[112.9217,27.6005],[112.9218,27.6006],[112.9219,27.6007],[112.922,27.6008],[112.9222,27.6009],[112.9223,27.6011],[112.9225,27.6012],[112.9226,27.6013],[112.9228,27.6014],[112.9229,27.6015],[112.9231,27.6016],[112.9233,27.6016],[112.9235,27.6017],[112.9236,27.6018],[112.9238,27.6019],[112.924,27.602],[112.9242,27.602],[112.9244,27.6021],[112.9246,27.6022],[112.9248,27.6022],[112.925,27.6023],[112.9252,27.6023],[112.9254,27.6024],[112.9256,27.6024],[112.9258,27.6025],[112.926,27.6025],[112.9263,27.6025],[112.9265,27.6026],[112.9267,27.6026],[112.9269,27.6026],[112.9271,27.6026],[112.9274,27.6026],[112.9276,27.6027],[112.9278,27.6027],[112.9281,27.6027],[112.9283,27.6027],[112.9285,27.6026],[112.9288,27.6026],[112.929,27.6026],[112.9292,27.6026],[112.9295,27.6026],[112.9297,27.6025],[112.93,27.6025],[112.9302,27.6025],[112.9304,27.6024],[112.9307,27.6024],[112.9309,27.6023],[112.9311,27.6023],[112.9314,27.6022],[112.9316,27.6022]]]]},\"properties\":{\"Id\":0,\"name\":\"2\",\"拆分\":\"羊\"},\"id\":\"范围2.3\"},{\"type\":\"Feature\",\"geometry\":{\"type\":\"MultiPolygon\",\"coordinates\":[[[[112.8893,27.5699],[112.8896,27.5698],[112.8899,27.5698],[112.8902,27.5697],[112.8904,27.5697],[112.8907,27.5696],[112.891,27.5696],[112.8912,27.5695],[112.8915,27.5694],[112.8917,27.5694],[112.892,27.5693],[112.8922,27.5692],[112.8925,27.5691],[112.8927,27.569],[112.893,27.5689],[112.8932,27.5688],[112.8935,27.5687],[112.8937,27.5686],[112.894,27.5685],[112.8942,27.5683],[112.8944,27.5682],[112.8946,27.5681],[112.8949,27.5679],[112.8951,27.5678],[112.8953,27.5676],[112.8955,27.5675],[112.8957,27.5673],[112.8959,27.5672],[112.8961,27.567],[112.8963,27.5668],[112.8965,27.5667],[112.8967,27.5665],[112.8968,27.5663],[112.897,27.5661],[112.8972,27.5659],[112.8973,27.5658],[112.8975,27.5656],[112.8976,27.5654],[112.8978,27.5652],[112.8979,27.565],[112.898,27.5648],[112.8982,27.5646],[112.8983,27.5644],[112.8984,27.5642],[112.8985,27.5639],[112.8986,27.5637],[112.8987,27.5635],[112.8988,27.5633],[112.8989,27.5631],[112.899,27.5629],[112.899,27.5626],[112.8991,27.5624],[112.8992,27.5622],[112.8992,27.562],[112.8993,27.5617],[112.8993,27.5615],[112.8993,27.5613],[112.8993,27.5611],[112.8994,27.5608],[112.8994,27.5606],[112.8994,27.5604],[112.8994,27.5601],[112.8994,27.5599],[112.8994,27.5597],[112.8993,27.5595],[112.8993,27.5592],[112.8993,27.559],[112.8992,27.5588],[112.8992,27.5586],[112.8991,27.5583],[112.8991,27.5581],[112.899,27.5579],[112.8989,27.5577],[112.8988,27.5575],[112.8988,27.5573],[112.8987,27.5571],[112.8986,27.5568],[112.8985,27.5566],[112.8984,27.5564],[112.8982,27.5562],[112.8981,27.556],[112.898,27.5558],[112.8979,27.5556],[112.8977,27.5555],[112.8976,27.5553],[112.8974,27.5551],[112.8973,27.5549],[112.8971,27.5547],[112.8969,27.5546],[112.8968,27.5544],[112.8966,27.5542],[112.8964,27.5541],[112.8962,27.5539],[112.896,27.5537],[112.8958,27.5536],[112.8956,27.5535],[112.8954,27.5533],[112.8952,27.5532],[112.895,27.553],[112.8948,27.5529],[112.8945,27.5528],[112.8943,27.5527],[112.8941,27.5526],[112.8938,27.5525],[112.8936,27.5524],[112.8934,27.5523],[112.8931,27.5522],[112.8929,27.5521],[112.8926,27.552],[112.8924,27.5519],[112.8921,27.5518],[112.8919,27.5518],[112.8916,27.5517],[112.8914,27.5517],[112.8911,27.5516],[112.8908,27.5516],[112.8906,27.5515],[112.8903,27.5515],[112.89,27.5515],[112.8898,27.5514],[112.8895,27.5514],[112.8892,27.5514],[112.889,27.5514],[112.8887,27.5514],[112.8884,27.5514],[112.8881,27.5514],[112.8879,27.5514],[112.8876,27.5514],[112.8873,27.5515],[112.8871,27.5515],[112.8868,27.5515],[112.8865,27.5516],[112.8863,27.5516],[112.886,27.5517],[112.8857,27.5517],[112.8855,27.5518],[112.8852,27.5519],[112.885,27.552],[112.8847,27.552],[112.8844,27.5521],[112.8842,27.5522],[112.8839,27.5523],[112.8837,27.5524],[112.8834,27.5525],[112.8832,27.5526],[112.883,27.5527],[112.8827,27.5529],[112.8825,27.553],[112.8823,27.5531],[112.8821,27.5533],[112.8818,27.5534],[112.8816,27.5535],[112.8814,27.5537],[112.8812,27.5538],[112.881,27.554],[112.8808,27.5542],[112.8806,27.5543],[112.8804,27.5545],[112.8802,27.5547],[112.88,27.5548],[112.8799,27.555],[112.8797,27.5552],[112.8795,27.5554],[112.8794,27.5556],[112.8792,27.5558],[112.8791,27.556],[112.8789,27.5562],[112.8788,27.5564],[112.8786,27.5566],[112.8785,27.5568],[112.8784,27.557],[112.8783,27.5572],[112.8782,27.5574],[112.8781,27.5576],[112.878,27.5578],[112.8779,27.558],[112.8778,27.5583],[112.8777,27.5585],[112.8777,27.5587],[112.8776,27.5589],[112.8775,27.5591],[112.8775,27.5594],[112.8774,27.5596],[112.8774,27.5598],[112.8774,27.56],[112.8773,27.5603],[112.8773,27.5605],[112.8773,27.5607],[112.8773,27.561],[112.8773,27.5612],[112.8773,27.5614],[112.8773,27.5616],[112.8774,27.5619],[112.8774,27.5621],[112.8774,27.5623],[112.8775,27.5625],[112.8775,27.5628],[112.8776,27.563],[112.8776,27.5632],[112.8777,27.5634],[112.8778,27.5636],[112.8778,27.5638],[112.8779,27.5641],[112.878,27.5643],[112.8781,27.5645],[112.8782,27.5647],[112.8783,27.5649],[112.8785,27.5651],[112.8786,27.5653],[112.8787,27.5655],[112.8788,27.5657],[112.879,27.5659],[112.8791,27.5661],[112.8793,27.5662],[112.8794,27.5664],[112.8796,27.5666],[112.8798,27.5668],[112.8799,27.5669],[112.8801,27.5671],[112.8803,27.5673],[112.8805,27.5674],[112.8807,27.5676],[112.8809,27.5677],[112.8811,27.5679],[112.8813,27.568],[112.8815,27.5682],[112.8817,27.5683],[112.8819,27.5684],[112.8822,27.5685],[112.8824,27.5687],[112.8826,27.5688],[112.8828,27.5689],[112.8831,27.569],[112.8833,27.5691],[112.8836,27.5692],[112.8838,27.5693],[112.8841,27.5693],[112.8843,27.5694],[112.8846,27.5695],[112.8848,27.5696],[112.8851,27.5696],[112.8853,27.5697],[112.8856,27.5697],[112.8859,27.5698],[112.8861,27.5698],[112.8864,27.5698],[112.8867,27.5699],[112.8869,27.5699],[112.8872,27.5699],[112.8875,27.5699],[112.8877,27.5699],[112.888,27.5699],[112.8883,27.5699],[112.8885,27.5699],[112.8888,27.5699],[112.8891,27.5699],[112.8893,27.5699]]]]},\"properties\":{\"Id\":0,\"name\":\"3\",\"拆分\":\"weslie\"},\"id\":\"范围2.4\"},{\"type\":\"Feature\",\"geometry\":{\"type\":\"MultiPolygon\",\"coordinates\":[[[[112.8923,27.6097],[112.8926,27.6097],[112.8929,27.6097],[112.8932,27.6097],[112.8936,27.6096],[112.8939,27.6096],[112.8942,27.6096],[112.8945,27.6095],[112.8948,27.6095],[112.8951,27.6094],[112.8954,27.6093],[112.8957,27.6093],[112.896,27.6092],[112.8963,27.6091],[112.8965,27.609],[112.8968,27.609],[112.8971,27.6089],[112.8974,27.6088],[112.8977,27.6087],[112.898,27.6085],[112.8982,27.6084],[112.8985,27.6083],[112.8988,27.6082],[112.899,27.6081],[112.8993,27.6079],[112.8995,27.6078],[112.8998,27.6076],[112.9,27.6075],[112.9003,27.6073],[112.9005,27.6072],[112.9007,27.607],[112.9009,27.6069],[112.9012,27.6067],[112.9014,27.6065],[112.9016,27.6063],[112.9018,27.6062],[112.902,27.606],[112.9022,27.6058],[112.9023,27.6056],[112.9025,27.6054],[112.9027,27.6052],[112.9028,27.605],[112.903,27.6048],[112.9032,27.6046],[112.9033,27.6044],[112.9034,27.6042],[112.9036,27.6039],[112.9036,27.6038],[112.9037,27.6037],[112.9038,27.6035],[112.9039,27.6034],[112.9039,27.6033],[112.904,27.6032],[112.904,27.6031],[112.9041,27.6029],[112.9041,27.6028],[112.9042,27.6027],[112.9042,27.6026],[112.9042,27.6025],[112.9043,27.6024],[112.9043,27.6023],[112.9044,27.6021],[112.9044,27.602],[112.9044,27.6019],[112.9045,27.6018],[112.9045,27.6017],[112.9045,27.6016],[112.9045,27.6014],[112.9046,27.6013],[112.9046,27.6012],[112.9046,27.6011],[112.9046,27.601],[112.9046,27.6009],[112.9046,27.6007],[112.9047,27.6006],[112.9047,27.6005],[112.9047,27.6004],[112.9047,27.6003],[112.9047,27.6001],[112.9047,27.6],[112.9047,27.5999],[112.9047,27.5998],[112.9047,27.5997],[112.9047,27.5996],[112.9047,27.5994],[112.9047,27.5993],[112.9046,27.5992],[112.9046,27.5991],[112.9046,27.599],[112.9046,27.5989],[112.9046,27.5987],[112.9046,27.5986],[112.9045,27.5985],[112.9045,27.5984],[112.9045,27.5983],[112.9045,27.5982],[112.9044,27.598],[112.9044,27.5979],[112.9044,27.5978],[112.9043,27.5977],[112.9043,27.5976],[112.9043,27.5975],[112.9042,27.5974],[112.9042,27.5972],[112.9041,27.5971],[112.9041,27.597],[112.904,27.5969],[112.904,27.5968],[112.9039,27.5967],[112.9039,27.5966],[112.9038,27.5965],[112.9038,27.5964],[112.9036,27.5961],[112.9036,27.596],[112.9035,27.5959],[112.9035,27.5958],[112.9034,27.5957],[112.9032,27.5955],[112.9031,27.5953],[112.9029,27.5951],[112.9028,27.5949],[112.9026,27.5947],[112.9025,27.5945],[112.9023,27.5943],[112.9021,27.5941],[112.9019,27.5939],[112.9017,27.5938],[112.9015,27.5936],[112.9013,27.5934],[112.9011,27.5932],[112.9009,27.5931],[112.9006,27.5929],[112.9004,27.5928],[112.9002,27.5926],[112.8999,27.5925],[112.8997,27.5923],[112.8994,27.5922],[112.8992,27.592],[112.8989,27.5919],[112.8987,27.5918],[112.8984,27.5917],[112.8981,27.5916],[112.8978,27.5915],[112.8976,27.5914],[112.8973,27.5913],[112.897,27.5912],[112.8967,27.5911],[112.8964,27.591],[112.8961,27.5909],[112.8959,27.5908],[112.8956,27.5908],[112.8953,27.5907],[112.895,27.5907],[112.8947,27.5906],[112.8944,27.5906],[112.8941,27.5905],[112.8937,27.5905],[112.8934,27.5905],[112.8931,27.5905],[112.8928,27.5905],[112.8925,27.5904],[112.8922,27.5904],[112.8919,27.5904],[112.8916,27.5905],[112.8913,27.5905],[112.891,27.5905],[112.8907,27.5905],[112.8904,27.5906],[112.8901,27.5906],[112.8897,27.5906],[112.8894,27.5907],[112.8891,27.5907],[112.8888,27.5908],[112.8885,27.5909],[112.8883,27.5909],[112.888,27.591],[112.8877,27.5911],[112.8874,27.5912],[112.8871,27.5913],[112.8868,27.5914],[112.8865,27.5915],[112.8863,27.5916],[112.886,27.5917],[112.8857,27.5918],[112.8855,27.592],[112.8852,27.5921],[112.8849,27.5922],[112.8847,27.5924],[112.8844,27.5925],[112.8842,27.5927],[112.884,27.5928],[112.8837,27.593],[112.8835,27.5931],[112.8833,27.5933],[112.8831,27.5935],[112.8829,27.5936],[112.8826,27.5938],[112.8824,27.594],[112.8822,27.5942],[112.8821,27.5944],[112.8819,27.5946],[112.8817,27.5948],[112.8815,27.595],[112.8814,27.5952],[112.8812,27.5954],[112.8811,27.5956],[112.8809,27.5958],[112.8808,27.596],[112.8806,27.5962],[112.8806,27.5963],[112.8805,27.5964],[112.8804,27.5966],[112.8803,27.5968],[112.8803,27.5969],[112.8802,27.597],[112.8802,27.5971],[112.8801,27.5972],[112.8801,27.5973],[112.8801,27.5974],[112.88,27.5975],[112.88,27.5977],[112.8799,27.5978],[112.8799,27.5979],[112.8799,27.598],[112.8798,27.5981],[112.8798,27.5982],[112.8798,27.5983],[112.8797,27.5985],[112.8797,27.5986],[112.8797,27.5987],[112.8797,27.5988],[112.8796,27.5989],[112.8796,27.5991],[112.8796,27.5992],[112.8796,27.5993],[112.8796,27.5994],[112.8796,27.5995],[112.8795,27.5996],[112.8795,27.5998],[112.8795,27.5999],[112.8795,27.6],[112.8795,27.6001],[112.8795,27.6002],[112.8795,27.6003],[112.8795,27.6005],[112.8795,27.6006],[112.8795,27.6007],[112.8796,27.6008],[112.8796,27.6009],[112.8796,27.6011],[112.8796,27.6012],[112.8796,27.6013],[112.8796,27.6014],[112.8796,27.6015],[112.8797,27.6016],[112.8797,27.6018],[112.8797,27.6019],[112.8798,27.602],[112.8798,27.6021],[112.8798,27.6022],[112.8798,27.6023],[112.8799,27.6024],[112.8799,27.6026],[112.88,27.6027],[112.88,27.6028],[112.88,27.6029],[112.8801,27.603],[112.8801,27.6031],[112.8802,27.6032],[112.8802,27.6034],[112.8803,27.6035],[112.8803,27.6036],[112.8804,27.6037],[112.8804,27.6038],[112.8806,27.604],[112.8806,27.6041],[112.8807,27.6042],[112.8808,27.6043],[112.8808,27.6044],[112.881,27.6046],[112.8811,27.6049],[112.8813,27.6051],[112.8814,27.6053],[112.8816,27.6055],[112.8818,27.6056],[112.8819,27.6058],[112.8821,27.606],[112.8823,27.6062],[112.8825,27.6064],[112.8827,27.6066],[112.8829,27.6067],[112.8831,27.6069],[112.8834,27.6071],[112.8836,27.6072],[112.8838,27.6074],[112.8841,27.6075],[112.8843,27.6077],[112.8845,27.6078],[112.8848,27.608],[112.885,27.6081],[112.8853,27.6082],[112.8856,27.6084],[112.8858,27.6085],[112.8861,27.6086],[112.8864,27.6087],[112.8866,27.6088],[112.8869,27.6089],[112.8872,27.609],[112.8875,27.6091],[112.8878,27.6092],[112.8881,27.6092],[112.8884,27.6093],[112.8887,27.6094],[112.889,27.6094],[112.8893,27.6095],[112.8896,27.6095],[112.8899,27.6096],[112.8902,27.6096],[112.8905,27.6096],[112.8908,27.6097],[112.8911,27.6097],[112.8914,27.6097],[112.8917,27.6097],[112.892,27.6097],[112.8923,27.6097]]]]},\"properties\":{\"Id\":0,\"name\":\"4\",\"拆分\":\"hui\"},\"id\":\"范围2.5\"},{\"type\":\"Feature\",\"geometry\":{\"type\":\"MultiPolygon\",\"coordinates\":[[[[112.9231,27.5854],[112.9235,27.5854],[112.9239,27.5853],[112.9243,27.5852],[112.9247,27.5851],[112.9251,27.585],[112.9255,27.5849],[112.9259,27.5849],[112.9263,27.5848],[112.9267,27.5847],[112.927,27.5845],[112.9274,27.5844],[112.9278,27.5843],[112.9282,27.5842],[112.9285,27.5841],[112.9289,27.5839],[112.9293,27.5838],[112.9296,27.5837],[112.93,27.5835],[112.9303,27.5834],[112.9307,27.5833],[112.931,27.5831],[112.9313,27.583],[112.9317,27.5828],[112.932,27.5827],[112.9323,27.5825],[112.9326,27.5823],[112.9329,27.5822],[112.9332,27.582],[112.9335,27.5818],[112.9338,27.5817],[112.934,27.5815],[112.9343,27.5813],[112.9346,27.5811],[112.9348,27.5809],[112.9351,27.5808],[112.9353,27.5806],[112.9355,27.5804],[112.9357,27.5802],[112.9359,27.58],[112.9361,27.5798],[112.9363,27.5796],[112.9365,27.5795],[112.9367,27.5793],[112.9368,27.5792],[112.9369,27.5791],[112.937,27.579],[112.937,27.5789],[112.9371,27.5788],[112.9372,27.5787],[112.9372,27.5786],[112.9373,27.5785],[112.9374,27.5784],[112.9374,27.5783],[112.9375,27.5782],[112.9376,27.5781],[112.9376,27.578],[112.9377,27.5779],[112.9377,27.5778],[112.9378,27.5777],[112.9378,27.5776],[112.9379,27.5775],[112.9379,27.5774],[112.938,27.5773],[112.938,27.5772],[112.938,27.5771],[112.9381,27.577],[112.9381,27.5769],[112.9381,27.5768],[112.9381,27.5767],[112.9382,27.5766],[112.9382,27.5765],[112.9382,27.5764],[112.9382,27.5763],[112.9382,27.5762],[112.9382,27.5762],[112.9382,27.5761],[112.9383,27.576],[112.9383,27.5759],[112.9383,27.5758],[112.9383,27.5757],[112.9383,27.5756],[112.9382,27.5755],[112.9382,27.5754],[112.9382,27.5753],[112.9382,27.5752],[112.9382,27.5751],[112.9382,27.575],[112.9382,27.5749],[112.9381,27.5749],[112.9381,27.5748],[112.9381,27.5747],[112.938,27.5746],[112.938,27.5745],[112.938,27.5744],[112.9379,27.5743],[112.9379,27.5742],[112.9378,27.5741],[112.9378,27.5741],[112.9378,27.574],[112.9377,27.5739],[112.9377,27.5738],[112.9376,27.5737],[112.9375,27.5736],[112.9375,27.5736],[112.9374,27.5735],[112.9374,27.5734],[112.9373,27.5733],[112.9372,27.5732],[112.9371,27.5732],[112.9371,27.5731],[112.937,27.573],[112.9369,27.5729],[112.9368,27.5729],[112.9367,27.5728],[112.9367,27.5727],[112.9366,27.5726],[112.9365,27.5726],[112.9364,27.5725],[112.9363,27.5724],[112.9362,27.5723],[112.9361,27.5723],[112.936,27.5722],[112.9359,27.5721],[112.9358,27.5721],[112.9357,27.572],[112.9356,27.5719],[112.9355,27.5719],[112.9352,27.5718],[112.935,27.5716],[112.9348,27.5715],[112.9345,27.5714],[112.9342,27.5713],[112.934,27.5712],[112.9337,27.5711],[112.9334,27.571],[112.9331,27.5709],[112.9328,27.5708],[112.9325,27.5707],[112.9322,27.5706],[112.9319,27.5706],[112.9316,27.5705],[112.9313,27.5704],[112.9309,27.5704],[112.9306,27.5703],[112.9302,27.5703],[112.9299,27.5702],[112.9295,27.5702],[112.9292,27.5701],[112.9288,27.5701],[112.9285,27.5701],[112.9281,27.57],[112.9277,27.57],[112.9273,27.57],[112.927,27.57],[112.9266,27.57],[112.9262,27.57],[112.9258,27.57],[112.9254,27.57],[112.925,27.57],[112.9246,27.57],[112.9242,27.57],[112.9238,27.5701],[112.9234,27.5701],[112.923,27.5701],[112.9226,27.5702],[112.9222,27.5702],[112.9218,27.5703],[112.9214,27.5703],[112.921,27.5704],[112.9206,27.5705],[112.9202,27.5705],[112.9198,27.5706],[112.9194,27.5707],[112.919,27.5708],[112.9186,27.5708],[112.9182,27.5709],[112.9178,27.571],[112.9174,27.5711],[112.917,27.5712],[112.9167,27.5713],[112.9163,27.5715],[112.9159,27.5716],[112.9155,27.5717],[112.9152,27.5718],[112.9148,27.5719],[112.9144,27.5721],[112.9141,27.5722],[112.9137,27.5723],[112.9134,27.5725],[112.913,27.5726],[112.9127,27.5728],[112.9124,27.5729],[112.912,27.5731],[112.9117,27.5732],[112.9114,27.5734],[112.9111,27.5736],[112.9108,27.5737],[112.9105,27.5739],[112.9102,27.5741],[112.9099,27.5742],[112.9097,27.5744],[112.9094,27.5746],[112.9091,27.5748],[112.9089,27.5749],[112.9086,27.5751],[112.9084,27.5753],[112.9082,27.5755],[112.908,27.5757],[112.9078,27.5759],[112.9076,27.5761],[112.9074,27.5762],[112.9072,27.5764],[112.907,27.5766],[112.9069,27.5767],[112.9068,27.5768],[112.9068,27.5769],[112.9067,27.577],[112.9066,27.5771],[112.9065,27.5772],[112.9065,27.5773],[112.9064,27.5774],[112.9063,27.5775],[112.9063,27.5776],[112.9062,27.5777],[112.9061,27.5778],[112.9061,27.5779],[112.906,27.578],[112.906,27.5781],[112.9059,27.5782],[112.9059,27.5783],[112.9058,27.5784],[112.9058,27.5785],[112.9057,27.5786],[112.9057,27.5787],[112.9057,27.5788],[112.9056,27.5789],[112.9056,27.579],[112.9056,27.5791],[112.9056,27.5792],[112.9055,27.5793],[112.9055,27.5794],[112.9055,27.5795],[112.9055,27.5795],[112.9055,27.5796],[112.9055,27.5797],[112.9055,27.5798],[112.9054,27.5799],[112.9054,27.58],[112.9054,27.5801],[112.9054,27.5802],[112.9054,27.5803],[112.9055,27.5804],[112.9055,27.5805],[112.9055,27.5806],[112.9055,27.5807],[112.9055,27.5808],[112.9055,27.5809],[112.9055,27.5809],[112.9056,27.581],[112.9056,27.5811],[112.9056,27.5812],[112.9057,27.5813],[112.9057,27.5814],[112.9057,27.5815],[112.9058,27.5816],[112.9058,27.5817],[112.9059,27.5817],[112.9059,27.5818],[112.9059,27.5819],[112.906,27.582],[112.906,27.5821],[112.9061,27.5822],[112.9062,27.5822],[112.9062,27.5823],[112.9063,27.5824],[112.9064,27.5825],[112.9064,27.5826],[112.9065,27.5827],[112.9066,27.5827],[112.9066,27.5828],[112.9067,27.5829],[112.9068,27.583],[112.9069,27.583],[112.907,27.5831],[112.907,27.5832],[112.9071,27.5833],[112.9072,27.5833],[112.9073,27.5834],[112.9074,27.5835],[112.9075,27.5835],[112.9076,27.5836],[112.9077,27.5837],[112.9078,27.5837],[112.9079,27.5838],[112.908,27.5839],[112.9081,27.5839],[112.9082,27.584],[112.9085,27.5841],[112.9087,27.5843],[112.9089,27.5844],[112.9092,27.5845],[112.9095,27.5846],[112.9097,27.5847],[112.91,27.5848],[112.9103,27.5849],[112.9106,27.585],[112.9109,27.5851],[112.9112,27.5852],[112.9115,27.5852],[112.9118,27.5853],[112.9121,27.5854],[112.9124,27.5855],[112.9128,27.5855],[112.9131,27.5856],[112.9135,27.5856],[112.9138,27.5857],[112.9142,27.5857],[112.9145,27.5858],[112.9149,27.5858],[112.9152,27.5858],[112.9156,27.5859],[112.916,27.5859],[112.9164,27.5859],[112.9167,27.5859],[112.9171,27.5859],[112.9175,27.5859],[112.9179,27.5859],[112.9183,27.5859],[112.9187,27.5859],[112.9191,27.5859],[112.9195,27.5858],[112.9199,27.5858],[112.9203,27.5858],[112.9207,27.5857],[112.9211,27.5857],[112.9215,27.5857],[112.9219,27.5856],[112.9223,27.5856],[112.9227,27.5855],[112.9231,27.5854]]]]},\"properties\":{\"Id\":0,\"name\":\"5\",\"拆分\":\"黑\"},\"id\":\"范围2.6\"}]}\n";
//        boolean result = intersectsGeo(a, jsonToWkt(JSONObject.parseObject(b)));
//        System.out.println(result);


        List<JsonNode> ks=convertShpToGeojsons( convertShpToGeojson("G:\\XQ\\jinzita\\caiqiemian\\caiqiemian.shp"));
        String m=convertShpToGeojson("G:\\XQ\\jinzita\\caiqiemian\\caiqiemian.shp");
        jsonToWkt(JSONObject.parseObject(m));
        String dg="G:\\XQ\\jinzita\\裁切\\polygon11.tif";

        Map kv= getImageXY(dg);
        kv.get("coverageMaxY");
        String lonlat1 = kv.get("coverageMinX")+ " " + kv.get("coverageMinY");
        String lonlat2 = kv.get("coverageMinX") + " " + kv.get("coverageMaxY");
        String lonlat3 = kv.get("coverageMaxX") + " " + kv.get("coverageMinY");
        String lonlat4 = kv.get("coverageMaxX") + " " + kv.get("coverageMaxY");
        String lonlats = lonlat1 + "," + lonlat2 + "," + lonlat4 + "," + lonlat3 + "," + lonlat1;
        System.out.println(jsonToWkt(JSONObject.parseObject(m)));
        boolean result = intersectsGeo(jsonToWkt(JSONObject.parseObject(m)),"polygon ((" + lonlats + "))");
        System.out.println(result);
//        ks.stream().filter(s->{
//             JSONObject j=JSONObject.parseObject(s.toString());
//            try {
//                boolean result = intersectsGeo("polygon ((" + lonlats + "))", jsonToWkt(j));
//                System.out.println(result);
//            } catch (ParseException e) {
//                throw new RuntimeException(e);
//            }
//            return s.asBoolean();}).collect(Collectors.toList());
//        convertShpToGeojsons("G:\\XQ\\jinzita\\caiqiemian\\caiqiemian.shp");
//        JSONObject k=JSONObject.parseObject(convertShpToGeojson("G:\\XQ\\jinzita\\caiqiemian\\caiqiemian.shp"));
//        System.out.println(jsonToWkt(k));
        System.out.println("================================");
    }

    // 定义一个将Shapefile文件转换成多个独立的Shapefile文件的方法，每个文件只包含一个多边形
   // 输入参数：shpurl - Shapefile文件的路径; drc - 输出文件夹的路径
    public static List<String> shptocf(String shpurl, String drc,String namess) throws IOException {
        ShpFileSpelitter shpFileSpelitter=new ShpFileSpelitter();
        isname(shpurl,namess,shpFileSpelitter);
        System.out.println(shpFileSpelitter.getName());
        List<String> shp_urls=new ArrayList<>();
        // 创建输入的 Shapefile 数据存储
        ShapefileDataStore inputDataStore = new ShapefileDataStore(new File(shpurl).toURI().toURL());
        inputDataStore.setCharset(StandardCharsets.UTF_8);
        // 获取输入的 SimpleFeature 集合
        SimpleFeatureCollection inputFeatureCollection = inputDataStore.getFeatureSource().getFeatures();
        // 创建输入的 SimpleFeature 迭代器
        SimpleFeatureIterator inputFeatureIterator = inputFeatureCollection.features();
        // 获取输入的几何字段的名字
        String inputGeometryFieldName = inputFeatureCollection.getSchema().getGeometryDescriptor().getLocalName();
        // 获取输入Shapefile的坐标系
        CoordinateReferenceSystem inputCRS = inputFeatureCollection.getSchema().getCoordinateReferenceSystem();
        // 遍历输入的 SimpleFeature
        try {
            while (inputFeatureIterator.hasNext()) {
                // 获取当前的 SimpleFeature
                SimpleFeature inputFeature = inputFeatureIterator.next();
                // 获取当前的几何对象
                Geometry inputGeometry = (Geometry) inputFeature.getAttribute(inputGeometryFieldName);
                // 获取当前 SimpleFeature 的类型
                SimpleFeatureType featureType = inputFeature.getType();
                // 判断几何对象是否为 MultiPolygon 类型
                if (inputGeometry instanceof MultiPolygon) {
                    // 将几何对象转换为 MultiPolygon 类型
                    MultiPolygon multiPolygon = (MultiPolygon) inputGeometry;
                    // 获取多边形的数量
                    int numOfPolygons = multiPolygon.getNumGeometries();
                    // 遍历每个多边形
                    for (int i = 0; i < numOfPolygons; i++) {
                        // 获取当前的多边形
                        Polygon polygon = (Polygon) multiPolygon.getGeometryN(i);
                        // 创建一个 SimpleFeatureBuilder 对象用于创建新的 SimpleFeature
                        SimpleFeatureBuilder featureBuilder = new SimpleFeatureBuilder(featureType);
                        // 创建一个存储属性值的列表
                        List<Object> attributeValues = new ArrayList<>();
                        // 遍历当前 SimpleFeature 的属性
                        for (int j = 0; j < featureType.getAttributeCount(); j++) {
                            // 如果当前属性为几何字段，则添加多边形对象
                            if (featureType.getDescriptor(j).getLocalName().equals(inputGeometryFieldName)) {
                                attributeValues.add(polygon);
                            } else {
                                // 其他属性添加原始值
                                attributeValues.add(inputFeature.getAttribute(j));
                            }
                        }
                        // 将属性值添加到 featureBuilder 中
                        featureBuilder.addAll(attributeValues);
                        // 使用 featureBuilder 构建新的 SimpleFeature 对象
                        SimpleFeature outputFeature = featureBuilder.buildFeature(null);


                        // 将新的 SimpleFeature 写入单独的 Shapefile 文件
                        saveFeatureToShapefile(outputFeature, drc, inputFeature.getID(),  i, inputCRS,shp_urls, shpFileSpelitter.getName());
                    }
                } else {
                    // 如果几何对象不是 MultiPolygon 类型，直接保存为 Shapefile 文件
                    saveFeatureToShapefile(inputFeature, drc, inputFeature.getID(), 0,inputCRS,shp_urls, shpFileSpelitter.getName());
                }
            }
        } finally {
            // 关闭输入的 SimpleFeature 迭代器
            inputFeatureIterator.close();
        }
        return shp_urls;
    }
    // 保存 SimpleFeature 对象到单独的 Shapefile 文件的辅助方法
    // 输入参数：feature - 要保存的 SimpleFeature；drc - 输出文件夹的路径；id - 用于构造输出文件名的ID字符串；
    private static void saveFeatureToShapefile(SimpleFeature feature, String drc, String id, int index,CoordinateReferenceSystem inputCRS,List<String> shp_urls,String namesss) throws IOException {
        // 创建一个 ShapefileDataStoreFactory 对象用于产生 Shapefile 数据存储
        ShapefileDataStoreFactory dataStoreFactory = new ShapefileDataStoreFactory();
        // 创建输出文件路径
        File outputFile = new File(drc + id + "_"+feature.getAttribute(namesss)+"_"+ index + ".shp");
        // 创建输出的 Shapefile 数据存储
        ShapefileDataStore outputDataStore = (ShapefileDataStore) dataStoreFactory.createDataStore(outputFile.toURI().toURL());
        // 创建一个 SimpleFeatureTypeBuilder 对象，用于构建新的 SimpleFeature 类型
        SimpleFeatureTypeBuilder typeBuilder = new SimpleFeatureTypeBuilder();
        outputDataStore.setCharset(StandardCharsets.UTF_8);
        // 设置 SimpleFeature 类型的名称
        typeBuilder.setName(feature.getType().getName());
        // 设置坐标参考系
        typeBuilder.setCRS(inputCRS != null ? inputCRS : DefaultGeographicCRS.WGS84);
        // 添加所有的属性描述符
        typeBuilder.addAll(feature.getType().getAttributeDescriptors());
        // 构建新的 SimpleFeature 类型
        SimpleFeatureType outputType = typeBuilder.buildFeatureType();
        // 创建输出的 SimpleFeature 类型的架构
        outputDataStore.createSchema(outputType);
        // 强制输出的 Shapefile 使用 WGS84 坐标参考系
        outputDataStore.forceSchemaCRS(inputCRS != null ? inputCRS : DefaultGeographicCRS.WGS84);
        // 创建一个事务对象，用于写入 Shapefile 的操作
        Transaction transaction = new DefaultTransaction("create");
        try {
            // 创建一个 FeatureWriter 对象，用于写入输出的 Shapefile
            FeatureWriter<SimpleFeatureType, SimpleFeature> featureWriter = outputDataStore.getFeatureWriterAppend(transaction);
            // 获取要写入的新 SimpleFeature 对象
            SimpleFeature newFeature = featureWriter.next();
            // 设置新 SimpleFeature 的属性
            newFeature.setAttributes(feature.getAttributes());
            // 写入 Shapefile
            featureWriter.write();
            // 提交事务
            transaction.commit();
            // 关闭 FeatureWriter
            featureWriter.close();
            shp_urls.add(outputFile.getAbsolutePath());
        } catch (Exception e) {
            // 如果写入过程中发生异常，则回滚事务
            e.printStackTrace();
            transaction.rollback();
        } finally {
            // 关闭事务
            transaction.close();
        }
    }

    //获取每个面对geojson,使用convertShpToGeojson结果
    public static List<JsonNode> convertShpToGeojsons(String sb) throws IOException {
        ObjectMapper objectMapper = new ObjectMapper(); // 创建ObjectMapper对象
        JsonNode rootNode = objectMapper.readTree(sb); // 直接将sb字符串解析成JsonNode对象，无需调用toString()方法
        List<JsonNode> rs = new ArrayList<>(); // 创建空的JsonNode列表
        for (JsonNode featureNode : rootNode.path("features")) { // 使用path()方法获取features节点下的数组节点，并遍历所有节点
            //在GeoJSON中，geometry类型可以是Point、LineString、Polygon等，而Polygon表示多边形
//            System.out.println("===================");
//            System.out.println(featureNode);
            rs.add(featureNode); // 将featureNode节点添加到rs列表中
//            String geometryType = featureNode.path("geometry").path("type").asText(); // 使用path()方法获取geometry节点下的type值
//            if ("Polygon".equals(geometryType)) { // 如果geometryType等于Polygon
//                rs.add(featureNode); // 将featureNode添加到rs列表中
//            }
        }
        return rs; // 返回rs列表
    }
    //获取shp的geojson
    public static String convertShpToGeojson(String shpFilePath) throws IOException {
        // 读取shp文件
        File shpFile = new File(shpFilePath); // 创建File对象，表示shpFilePath路径下的文件
        Map<String, Object> params = new HashMap<String, Object>(); // 创建Map对象，存储参数信息
        params.put("url", shpFile.toURI().toURL()); // 将shp文件的URL放入params中
        params.put("charset", "UTF-8"); // 设置编码格式为utf-8
        DataStore store = DataStoreFinder.getDataStore(params); // 获取DataStore对象
        String typeName = store.getTypeNames()[0]; // 获取shp文件类型名
        SimpleFeatureCollection collection = store.getFeatureSource(typeName).getFeatures(); // 获取shp文件的要素集合
        // 转为geojson
        FeatureJSON featureJSON = new FeatureJSON(); // 创建FeatureJSON对象
        SimpleFeatureIterator iterator = collection.features(); // 获取集合的迭代器
        StringBuilder sb = new StringBuilder("{\"type\":\"FeatureCollection\",\"features\":["); // 创建StringBuilder对象，初始化为GeoJSON的头部
        try {
            while (iterator.hasNext()) { // 如果还有下一个要素
                SimpleFeature feature = iterator.next(); // 获取下一个要素
                String json = featureJSON.toString(feature); // 将要素对象转化成字符串
                sb.append(json).append(","); // 将json字符串添加到sb中
            }
            if (sb.length() > 1) { // 如果sb长度大于1
                sb.deleteCharAt(sb.length() - 1); // 删除sb的最后一个字符
            }
        } finally { // 再次保证迭代器能够被关闭
            iterator.close(); // 关闭迭代器
        }
        sb.append("]}"); // 在sb的尾部添加GeoJSON的结尾
        return sb.toString(); // 返回sb的字符串形式
    }
    //wkt转geojson
    public static String wktToJson(String wkt) {
        String json = null;
        try {
            WKTReader reader = new WKTReader();
            Geometry geometry = reader.read(wkt);
            StringWriter writer = new StringWriter();
            GeometryJSON g = new GeometryJSON(20);
            g.write(geometry, writer);
            json = writer.toString();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return json;
    }
    //geojson转wkt
    public static String jsonToWkt(JSONObject jsonObject) {
        String wkt = null;
        String type = jsonObject.getString("type");
        GeometryJSON gJson = new GeometryJSON();
        try {
            // {"geometries":[{"coordinates":[4,6],"type":"Point"},{"coordinates":[[4,6],[7,10]],"type":"LineString"}],"type":"GeometryCollection"}
            if (ShpFileSpelitter.GEO_JSON_TYPE.equals(type)) {
                // 由于解析上面的json语句会出现这个geometries属性没有采用以下办法
                JSONArray geometriesArray = jsonObject.getJSONArray("geometries");
                // 定义一个数组装图形对象
                int size = geometriesArray.size();
                Geometry[] geometries = new Geometry[size];
                for (int i = 0; i < size; i++) {
                    String str = geometriesArray.get(i).toString();
                    // 使用GeoUtil去读取str
                    Reader reader = GeoJSONUtil.toReader(str);
                    Geometry geometry = gJson.read(reader);
                    geometries[i] = geometry;
                }
                GeometryCollection geometryCollection = new GeometryCollection(geometries, new GeometryFactory());
                wkt = geometryCollection.toText();
            } else {
                Reader reader = GeoJSONUtil.toReader(jsonObject.toString());
                Geometry read = gJson.read(reader);
                wkt = read.toText();
            }
        } catch (IOException e) {
            System.out.println("GeoJson转WKT出现异常");
            e.printStackTrace();
        }
        return wkt;
    }
    //对shp属性字段判断
    public static boolean isname(String url,String namess,ShpFileSpelitter shpFileSpelitter) throws IOException {
        // 设置shp文件路径
        File file = new File(url);
        // 设置shp文件路径
        // 打开shp文件并获取FeatureSource对象
        ShapefileDataStoreFactory dataStoreFactory = new ShapefileDataStoreFactory();
        ShapefileDataStore shpDataStore = (ShapefileDataStore) dataStoreFactory
                .createDataStore(file.toURI().toURL());
        shpDataStore.setCharset(Charset.forName(String.valueOf(StandardCharsets.UTF_8)));
        SimpleFeatureSource featureSource = shpDataStore.getFeatureSource();
        // 获取SimpleFeatureType对象并遍历属性字段名称
        SimpleFeatureType schema = featureSource.getSchema();
        boolean f= schema.getDescriptors().stream().anyMatch(s->s.getName().toString().equals(namess));
        shpFileSpelitter.setvalue(namess);
        if (!f){
            shpFileSpelitter.setName(schema.getDescriptor(1).getName().toString());
        }
        // 关闭DataStore
        shpDataStore.dispose();
        return f;
    }
    private static GeometryFactory geometryFactory = new GeometryFactory(new PrecisionModel(), 4326);
    public static boolean intersectsGeo(String geometry3,String geometry4) throws ParseException{
        WKTReader reader = new WKTReader( geometryFactory );
        Geometry geometry1 =  reader.read(geometry3);
        Geometry geometry2 =  reader.read(geometry4);
        Geometry interPoint = geometry1.intersection(geometry2);//相交点
        System.out.println(interPoint.toText());//输出 POINT (0 0)
        return geometry1.intersects(geometry2);
    }
}
